package com.sky.controller.user;

import com.sky.result.Result;
import com.sky.service.DishService;
import com.sky.vo.DishVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 菜品相关功能
 *
 * @Author itcast
 * @Create 2023/3/7
 **/
@RestController("userDishController")
@RequestMapping("/user/dish")
@Slf4j
@Api(tags = "菜品相关接口")
public class DishController {

    @Autowired
    private DishService dishService;


    /**
     * 根据id查询菜品
     * @return
     */
    @ApiOperation("根据id查询菜品")
    @GetMapping("/{id}")
    public Result findById(@PathVariable Integer id){
        DishVO dishVO= dishService.findById(id);

        return Result.success(dishVO);
    }

    /**
     * 根据分类查询菜品
     * @return
     */
    @ApiOperation("根据分类查询菜品")
    @GetMapping("/list")
    public Result findByCategoryId(Long categoryId){
        List<DishVO> dishVOS= dishService.findByCategoryId(categoryId);

        return Result.success(dishVOS);
    }





}
